<template>
	<view class="pb115 o-h" :style="{ background: layout?layout.pageSetting[0].styles.moduleTitle == 1 ? layout.pageSetting[0].styles.colorIcon : 'url('+layout.pageSetting[0].styles.img+')':'' }">
		<!-- #ifndef H5 -->
		<uni-nav-bar v-if="layout.pageSetting[0].styles.modulePage==1" id='uninavbar' uropcity="1" :isleft="false" :fixed='true'
		 :ispr='true' :statusBar="true" :border='false' :bg='layout.pageSetting[0].styles.colorBg' :color="layout.pageSetting[0].styles.colorWord"
		 :title="layout.pageSetting[0].styles.navTitle">
		</uni-nav-bar>
		<!-- <uni-nav-bar v-else id='uninavbar' :isleft="false" :uropcity="opcity" :fixed='true' :ispr='false' :statusBar="true"
		 :border="opcity>=1" :title="layout.pageSetting[0].styles.navTitle">
		</uni-nav-bar> -->
		<!-- #endif -->
		<!-- 关注条 -->
		<view v-for="(v, i) in layout.attention" :key="i">
			<atten-tion :styles="v.styles" v-if="v.name == 'attention'"></atten-tion>
		</view>

		<!-- 搜索框 -->
		<block v-for="(v, i) in layout.list" :key="i">
			<!-- 搜索框 -->
			<search-box :co="v.styles" v-if="v.name == 'search'"></search-box>

			<!-- 定位 -->
			<fixed-set :co="v.styles" v-else-if="v.name == 'fixed'"></fixed-set>

			<!-- 公告 -->
			<notice-sue :co="v.styles" v-else-if="v.name == 'notice'"></notice-sue>

			<!-- 图片轮播 -->
			<picLunbo-by :styles="v.styles" v-else-if="v.name == 'picLunbo'"></picLunbo-by>

			<!-- 按钮组 -->
			<btn-group :styles="v.styles" v-else-if="v.name == 'btn'"></btn-group>

			<pictures :co="v.styles" v-else-if="v.name == 'pictures'"></pictures>

			<!-- 标题栏 -->
			<titles-bar :co="v.styles" v-else-if="v.name == 'titles'"></titles-bar>

			<blank :co="v.styles" v-else-if="v.name == 'blank'"></blank>

			<!-- 辅组线 -->
			<lines-wire :co="v.styles" v-else-if="v.name == 'lines'"></lines-wire>

			<!-- 更多门店 -->
			<store-Message :co="v.styles" v-else-if="v.name == 'storeMessage'"></store-Message>

			<!-- 富文本 -->
			<book-text :co="v.styles" v-else-if="v.name == 'book'"></book-text>

			<!-- 选项卡 -->
			<card-tab :styles="v.styles" v-else-if="v.name == 'card'"></card-tab>

			<!-- 热区 -->
			<hot-spots :co="v.styles" v-else-if="v.name == 'hot'"></hot-spots>

			<!-- 魔方 -->
			<margic-cube :co="v.styles" v-else-if="v.name == 'margic'"></margic-cube>
			<!-- 列表导航 -->
			<list-Nav :co="v.styles" v-else-if="v.name == 'listNav'"></list-Nav>
			<!-- 优惠券 -->
			<discount-coupons :styles="v.styles" v-else-if="v.name == 'discount'"></discount-coupons>

			<!-- 商品组 -->
			<product-group :styles="v.styles" v-else-if="v.name == 'product'"></product-group>
		</block>
		<!-- 悬浮设置 -->
		<view class="p-a" v-for="(v, i) in layout.susBtn" :key="i">
			<sus-btn :styles="v.styles" v-if="v.name == 'susBtn'"></sus-btn>
		</view>


		<!-- 下单提示 -->
		<view v-for="(v, i) in layout.remind" :key="i">
			<order-prompt :styles="v.styles" v-if="v.name == 'remind'"></order-prompt>
		</view>

		<!-- 引导页 -->

		<!-- <view v-for="(v, i) in layout.open" :key="i"><open-list :styles="v.styles" v-if="v.name == 'open'"></open-list></view> -->
		<tab-bar></tab-bar>
		<load v-if="showloading"></load>
	</view>
</template>
<script>
	import searchBox from '@/components/drag/search.vue';
	import fixedSet from '@/components/drag/fixed.vue';
	import noticeSue from '@/components/drag/notice.vue';
	import picLunboBy from '@/components/drag/picLunbo.vue';
	import btnGroup from '@/components/drag/btn.vue';
	import pictures from '@/components/drag/pictures.vue';
	import titlesBar from '@/components/drag/titles.vue';
	import blank from '@/components/drag/blank.vue';
	import linesWire from '@/components/drag/lines.vue';
	import storeMessage from '@/components/drag/storeMessage.vue';
	import bookText from '@/components/common/functionCmp/rich-text.vue';
	import cardTab from '@/components/drag/card.vue';
	import hotSpots from '@/components/drag/hot.vue';
	import margicCube from '@/components/drag/margic.vue';
	import listNav from '@/components/drag/listNav.vue';
	import discountCoupons from '@/components/drag/discount.vue';
	import productGroup from '@/components/drag/product.vue';
	import susBtn from '@/components/drag/susBtn.vue';
	import attenTion from '@/components/drag/attenTion.vue';
	import orderPrompt from '@/components/drag/remind.vue';
	import openList from '@/components/drag/open.vue';
	import uniNavBar from "@/components/third/uni-nav-bar.vue"
	import load from '@/components/common/load.vue'
	import {
		mapActions,
		mapState
	} from 'vuex';
	import {
		getDw
	} from "@/common/wechat-util.js"
	export default {
		name: 'index',
		data() {
			return {
				showloading: true,
				opcity: 0,
			};
		},
		components: {
			searchBox,
			fixedSet,
			noticeSue,
			picLunboBy,
			btnGroup,
			pictures,
			titlesBar,
			blank,
			linesWire,
			storeMessage,
			bookText,
			cardTab,
			hotSpots,
			margicCube,
			listNav,
			discountCoupons,
			productGroup,
			susBtn,
			attenTion,
			orderPrompt,
			openList,
			uniNavBar,
			load,
		},

		onLoad(options) {
			this.query = options
			this.xlsx(options)
		},
		onShow() {},
		computed: {
			...mapState('dndc', ['latLng']),
			...mapState({
				layout: state => state.layout.index.body
			})
		},
		methods: {
			...mapActions(["getConfig"]),
			async xlsx(options) {
				this.getLayout().then(res => {
					this.showloading = false
				})
				let lc = await getDw({
					t: 0
				})
				this.getAddInfo(lc)
				this.refreshInfo()
				this.getSystem();
			},
			async refreshInfo() {
				let {
					data
				} = await this.util.request({
					'url': this.api.zjdp,
					data: {
						lat: this.latLng.lat,
						lng: this.latLng.lng,
					}
				})
				this.storeId = data.id
				this.getConfig({
					key: 'storeInfo',
					data: {
						id: data.id,
						name: data.name,
						distance: data.distance
					}
				})
				this.getLoginInfo({
					inviteId: this.query.userId
				}).then(() => {
					setTimeout(() => {
						this.addFwjl({
							storeId: this.storeId,
							origin: '首页'
						})
					}, 1000)
				});
			},
		},
		onPageScroll(e) {
			if (this.opcity >= 1 && e.scrollTop / 64 >= 1) {
				return;
			}
			let o = e.scrollTop / 64
			this.opcity = o;
		},
	};
</script>
<style lang="scss" scoped>
</style>
